Geo maps
The GeoMap control draws a map from a GeoJSON file: every feature of the
file is a land (a country, a state, a region) drawn as a vector shape. A world map is built in. A HeatLandSeries
gives a value to some of the lands and paints each one with a color taken from a gradient, the result is a
choropleth map.
This article highlights the most used features. Every property is listed in the API explorer:
GeoMap,
HeatLandSeries and
GeoMapChart (the CoreChart of the control).
Basic map
Add a HeatLandSeries to the Series of the map and fill its Lands with HeatLand items. The Name of a
HeatLand is the short name of a land in the map, and its Value sets the color of that land. In the built-in world
map the short names are the ISO 3166-1 alpha-3 codes in lowercase,
bra for Brazil or usa for the United States; the full list is in
word-map-index.json.
Write the names in lowercase: the map stores every short name in lowercase and finds lands with a case-sensitive
match, so BRA paints nothing.
Lands with no value keep the Fill of the map. The map is updated when a Value changes or when Lands is replaced:
this sample sets random values every half second, and the ToggleBrazil command of its view model (no button calls
it in the sample views) replaces Lands with a copy without Brazil, and back.

@page "/Maps/World"
@using LiveChartsCore.SkiaSharpView.Blazor
@using LiveChartsCore.Geo;
@using LiveChartsCore.SkiaSharpView;
@using LiveChartsCore.SkiaSharpView.Drawing.Geometries
@using LiveChartsCore.Measure
@using LiveChartsCore.SkiaSharpView.SKCharts
@using LiveChartsCore.SkiaSharpView.VisualElements
<GeoMap
@ref="Chart"
Series="@series"
MapProjection="LiveChartsCore.Geo.MapProjection.Mercator">
</GeoMap>
@code {
public GeoMap Chart;
private HeatLand[] lands = new HeatLand[]
{
new() { Name = "bra", Value = 13 },
new() { Name = "mex", Value = 10 },
new() { Name = "usa", Value = 15 },
new() { Name = "can", Value = 8 },
new() { Name = "ind", Value = 12 },
new() { Name = "deu", Value = 13 },
new() { Name= "jpn", Value = 15 },
new() { Name = "chn", Value = 14 },
new() { Name = "rus", Value = 11 },
new() { Name = "fra", Value = 8 },
new() { Name = "esp", Value = 7 },
new() { Name = "kor", Value = 10 },
new() { Name = "zaf", Value = 12 },
new() { Name = "are", Value = 13 }
};
private HeatLandSeries[] series;
protected override void OnInitialized()
{
series = new HeatLandSeries[]
{
new HeatLandSeries { Lands = lands }
};
_ = DoRandomChanges(series[0]);
}
protected override void OnAfterRender(bool firstRender)
{
base.OnAfterRender(firstRender);
if (!firstRender) return;
// the map title and legend are not component parameters,
// so set them on the control.
Chart.LegendPosition = LegendPosition.Right;
Chart.Title = new DrawnLabelVisual(
new LabelGeometry
{
Text = "World population by country",
TextSize = 20,
Padding = new LiveChartsCore.Drawing.Padding(12)
});
Chart.Legend = new SKHeatLegend
{
BadgePadding = new LiveChartsCore.Drawing.Padding(20, 16, 8, 16)
};
Chart.CoreChart?.Update();
}
private async Task DoRandomChanges(HeatLandSeries series)
{
var r = new Random();
await Task.Delay(1000);
while (true)
{
foreach (var shape in series.Lands ?? Enumerable.Empty<IWeigthedMapLand>())
{
shape.Value = r.Next(0, 20);
}
await Task.Delay(500);
}
}
}
This sample uses the Mercator projection, see map projections.
A map draws the borders of the GeoJSON file it is given. Some borders are disputed (Crimea, Taiwan, Western Sahara, Kashmir and others) and no single file satisfies every audience. If the borders of the built-in map do not match what you need, load another file, see custom maps.
Heat map colors
HeatMap is an array of LvcColor, it needs at
least two colors. The first color is used for the lowest value (the "coldest") and the last one for the highest (the
"hottest"), any value in between gets a color interpolated linearly between them. When it is not set, the gradient
goes from light blue to dark blue.

using SkiaSharp;
using LiveChartsCore.SkiaSharpView;
using LiveChartsCore.SkiaSharpView.Drawing.Geometries;
Series = new HeatLandSeries[]
{
new HeatLandSeries
{
HeatMap = new[] // mark
{ // mark
SKColors.LightPink.AsLvcColor(), // the first element is the "coldest" // mark
SKColors.Pink.AsLvcColor(), // mark
SKColors.DeepPink.AsLvcColor() // the last element is the "hottest" // mark
}, // mark
Lands = new HeatLand[]
{
new HeatLand { Name = "bra", Value = 13 },
new HeatLand { Name = "mex", Value = 10 },
new HeatLand { Name = "usa", Value = 15 },
new HeatLand { Name = "deu", Value = 13 },
new HeatLand { Name = "fra", Value = 8 },
new HeatLand { Name = "kor", Value = 10 },
new HeatLand { Name = "zaf", Value = 12 },
new HeatLand { Name = "are", Value = 13 }
}
}
};
By default the gradient goes from the lowest to the highest value in Lands. Set MinValue and MaxValue to fix
that range, for example to keep the same colors while the data changes; values outside the range take the first or
the last color. The heat legend shows the same range.
ColorStops sets where each color of the HeatMap is placed in the gradient, from 0 to 1, with one item for each
color. It works as in the heat series, see
color stops.
Stroke and fill
Stroke and Fill are properties of the map, not of the series. Stroke draws the border of every land, white by
default. Fill paints the lands that have no value in any series, light gray by default; the lands with a value keep
their heat color.
<GeoMap
Series="series"
Stroke="stroke"> <!-- mark -->
</GeoMap>
@code {
private SolidColorPaint stroke = new SolidColorPaint(SKColors.Red) { StrokeThickness = 2 }; // mark
// ...
}

<GeoMap
Series="series"
Fill="fill"> <!-- mark -->
</GeoMap>
@code {
private SolidColorPaint fill = new SolidColorPaint(SKColors.LightPink); // mark
// ...
}

On the orthographic projection, Fill also paints the disc of the globe.
Paints can also draw gradients and dashed lines, see the Paints article.
Map projections
MapProjection sets how longitudes and latitudes are placed on the screen. The map keeps the aspect ratio of the
projection and is centered in the control.
| Value | Result |
|---|---|
Default |
The default. Longitude and latitude are used as X and Y directly (an equirectangular map). |
Mercator |
The projection of most web maps; it keeps the shapes and stretches the areas near the poles. |
Orthographic |
A globe: only the hemisphere that faces the viewer is drawn, lands are cut at the horizon. |
<GeoMap
Series="series"
MapProjection="LiveChartsCore.Geo.MapProjection.Mercator"> <!-- mark -->
</GeoMap>
The basic map uses Mercator. This is the same data with the Default projection:

And with Orthographic, which faces longitude 0 and latitude 0 until you rotate it, see
rotate the globe:

Map bounds
MinLatitude, MaxLatitude, MinLongitude and MaxLongitude crop the map to a region, in degrees. They are
double.NaN by default, which keeps the default of the projection: Mercator goes from latitude -65 to 85, which
leaves out the empty band around Antarctica and keeps Greenland, and Default shows the whole earth. Set
MinLatitude to -85 to show Antarctica on a Mercator map.
Set the four bounds to focus on a region. These bounds frame Europe, from Iceland to the Caucasus and from the coast of North Africa to the North Cape:
<GeoMap
Series="series"
MapProjection="LiveChartsCore.Geo.MapProjection.Mercator"
MinLatitude="35"
MaxLatitude="72"
MinLongitude="-25"
MaxLongitude="45"> <!-- mark -->
</GeoMap>

The same bounds work with the Default projection, without the stretching of Mercator:

The orthographic projection ignores the bounds, rotate the globe instead.
Rotate the globe
On the orthographic projection, CenterLongitude and CenterLatitude of the CoreChart set the point the globe
faces. Setting them turns the globe at once; RotateTo(longitude, latitude, durationMs) animates the rotation, in
800 ms by default, and takes the shortest way around the globe. The other projections do not use these properties.
// faces Europe and Africa at once
geoMap.CoreChart.CenterLongitude = 15; // mark
geoMap.CoreChart.CenterLatitude = 20; // mark
// rotates to Tokyo
geoMap.CoreChart.RotateTo(longitude: 139.69, latitude: 35.69); // mark

The rotating orthographic sample calls RotateTo every 5 seconds, from North America (-95, 35) to Asia
(100, 35) and back. The view starts the loop when it is loaded, with
vm.Start((lon, lat) => geoMap.CoreChart.RotateTo(lon, lat)), and stops it when it is unloaded; the view model posts
each call to the UI thread:

@page "/Maps/RotatingOrthographic"
@using System.Threading
@using LiveChartsCore.SkiaSharpView.Blazor
@using LiveChartsCore.Geo
@using LiveChartsCore.SkiaSharpView
@using LiveChartsCore.SkiaSharpView.Drawing.Geometries
@implements IDisposable
<GeoMap
@ref="Chart"
Series="@series"
MapProjection="LiveChartsCore.Geo.MapProjection.Orthographic">
</GeoMap>
@code {
public GeoMap Chart;
private HeatLandSeries[] series =
[
new HeatLandSeries
{
Lands = new HeatLand[]
{
new() { Name = "bra", Value = 13 },
new() { Name = "mex", Value = 10 },
new() { Name = "usa", Value = 15 },
new() { Name = "can", Value = 8 },
new() { Name = "ind", Value = 12 },
new() { Name = "deu", Value = 13 },
new() { Name = "jpn", Value = 15 },
new() { Name = "chn", Value = 14 },
new() { Name = "rus", Value = 11 },
new() { Name = "fra", Value = 8 },
new() { Name = "esp", Value = 7 },
new() { Name = "kor", Value = 10 },
new() { Name = "zaf", Value = 12 },
new() { Name = "are", Value = 13 },
new() { Name = "aus", Value = 9 },
new() { Name = "arg", Value = 6 },
new() { Name = "egy", Value = 7 },
new() { Name = "nga", Value = 11 },
new() { Name = "gbr", Value = 9 }
}
}
];
// the globe turns to the next point every 5 seconds
private readonly (double Lon, double Lat)[] path =
[
(-95, 35), // North America
(100, 35) // Asia
];
private readonly CancellationTokenSource cts = new();
protected override void OnAfterRender(bool firstRender)
{
if (firstRender) _ = RotateLoop();
}
private async Task RotateLoop()
{
// let the map finish loading before the first rotation
await Task.Yield();
var i = 0;
while (!cts.IsCancellationRequested)
{
var (lon, lat) = path[i];
Chart.CoreChart?.RotateTo(lon, lat);
try { await Task.Delay(TimeSpan.FromSeconds(5), cts.Token); }
catch (OperationCanceledException) { return; }
i = (i + 1) % path.Length;
}
}
public void Dispose() => cts.Cancel();
}
Custom maps
ActiveMap is the map the control draws, the built-in world map by default. Load your own GeoJSON file with
Maps.GetMapFromDirectory(path) or Maps.GetMapFromStreamReader(reader), from the LiveChartsCore.Geo namespace,
and assign the result to ActiveMap. DrawnMap.GetMapFromDirectoryAsync(path) and
DrawnMap.GetMapFromStreamReaderAsync(reader) load the file on another thread.
The map reads the Polygon and MultiPolygon features of the file, other geometry types are skipped. Each feature
needs a name property, shown in the tooltip, and should have a shortName property, the name the series use; when
shortName is missing, the name is used instead. Both are read in lowercase.
This sample loads the states of Mexico from a file embedded in the assembly, gives a value to each state, and crops the map with the map bounds:

@page "/Maps/CustomMap"
@using System.IO
@using LiveChartsCore.SkiaSharpView.Blazor
@using LiveChartsCore.Geo
@using LiveChartsCore.SkiaSharpView
@using LiveChartsCore.SkiaSharpView.Drawing.Geometries
<GeoMap
@ref="Chart"
Series="@series"
ActiveMap="@activeMap"
MapProjection="LiveChartsCore.Geo.MapProjection.Mercator"
MinLatitude="13"
MaxLatitude="33"
MinLongitude="-120"
MaxLongitude="-85">
</GeoMap>
@code {
public GeoMap Chart;
private DrawnMap activeMap = LoadMap();
private HeatLandSeries[] series =
[
new HeatLandSeries
{
Name = "Population (synthetic)",
// the names are the ISO 3166-2 region codes without the 'mx-' prefix
Lands =
[
new HeatLand { Name = "agu", Value = 13 }, // Aguascalientes
new HeatLand { Name = "bcn", Value = 36 }, // Baja California
new HeatLand { Name = "bcs", Value = 8 }, // Baja California Sur
new HeatLand { Name = "cam", Value = 10 }, // Campeche
new HeatLand { Name = "chp", Value = 56 }, // Chiapas
new HeatLand { Name = "chh", Value = 38 }, // Chihuahua
new HeatLand { Name = "cmx", Value = 92 }, // Ciudad de México
new HeatLand { Name = "coa", Value = 32 }, // Coahuila
new HeatLand { Name = "col", Value = 7 }, // Colima
new HeatLand { Name = "dur", Value = 18 }, // Durango
new HeatLand { Name = "gua", Value = 62 }, // Guanajuato
new HeatLand { Name = "gro", Value = 35 }, // Guerrero
new HeatLand { Name = "hid", Value = 31 }, // Hidalgo
new HeatLand { Name = "jal", Value = 84 }, // Jalisco
new HeatLand { Name = "mex", Value = 170 }, // México (state)
new HeatLand { Name = "mic", Value = 47 }, // Michoacán
new HeatLand { Name = "mor", Value = 19 }, // Morelos
new HeatLand { Name = "nay", Value = 12 }, // Nayarit
new HeatLand { Name = "nle", Value = 58 }, // Nuevo León
new HeatLand { Name = "oax", Value = 41 }, // Oaxaca
new HeatLand { Name = "pue", Value = 65 }, // Puebla
new HeatLand { Name = "que", Value = 23 }, // Querétaro
new HeatLand { Name = "roo", Value = 18 }, // Quintana Roo
new HeatLand { Name = "slp", Value = 28 }, // San Luis Potosí
new HeatLand { Name = "sin", Value = 30 }, // Sinaloa
new HeatLand { Name = "son", Value = 29 }, // Sonora
new HeatLand { Name = "tab", Value = 24 }, // Tabasco
new HeatLand { Name = "tam", Value = 35 }, // Tamaulipas
new HeatLand { Name = "tla", Value = 13 }, // Tlaxcala
new HeatLand { Name = "ver", Value = 80 }, // Veracruz
new HeatLand { Name = "yuc", Value = 23 }, // Yucatán
new HeatLand { Name = "zac", Value = 15 }, // Zacatecas
],
},
];
private static DrawnMap LoadMap()
{
// the mexico-states.geojson file is an embedded resource of the ViewModelsSamples
// assembly, Maps also exposes GetMapFromDirectory(path) for files on disk
using var stream = typeof(ViewModelsSamples.Index).Assembly
.GetManifestResourceStream("ViewModelsSamples.Maps.CustomMap.mexico-states.geojson")!;
using var reader = new StreamReader(stream);
return LiveChartsCore.Geo.Maps.GetMapFromStreamReader(reader);
}
}
Markers on the map
The map draws its VisualElements on top of the lands, as the other charts do. Wrap a
Visual in a GeoVisualElement and set its
Longitude and Latitude to pin it to a place: the map moves the visual to that place on every update, so it
follows the zoom, the pan and the rotation of the globe. When the place is on the hidden side of the globe, the visual
is not drawn.
In this sample, CityMarkerVisual draws a circle, and a GeoVisualElement places one at each city. The visual must
not set the position of its drawn element in Measure, because that is where the map writes the projected position;
the TranslateTransform centers the circle on that point.

@page "/Maps/MarkersOnMap"
@using LiveChartsCore.SkiaSharpView.Blazor
@using LiveChartsCore.Geo
@using LiveChartsCore.SkiaSharpView
@using LiveChartsCore.SkiaSharpView.Drawing.Geometries
@using ViewModelsSamples.Maps.MarkersOnMap
<GeoMap
@ref="Chart"
Series="@series"
MapProjection="LiveChartsCore.Geo.MapProjection.Mercator">
</GeoMap>
@code {
public GeoMap Chart;
private HeatLandSeries[] series =
[
new HeatLandSeries
{
Lands =
[
new HeatLand { Name = "usa", Value = 15 },
new HeatLand { Name = "jpn", Value = 14 },
new HeatLand { Name = "esp", Value = 10 },
new HeatLand { Name = "bra", Value = 12 },
new HeatLand { Name = "aus", Value = 11 },
],
},
];
protected override void OnAfterRender(bool firstRender)
{
base.OnAfterRender(firstRender);
if (!firstRender) return;
// the map visual elements are not a component parameter,
// so set them on the control.
Chart.VisualElements =
[
CityMarker(longitude: -74.00, latitude: 40.71), // New York
CityMarker(longitude: 139.69, latitude: 35.69), // Tokyo
CityMarker(longitude: -3.70, latitude: 40.42), // Madrid
CityMarker(longitude: -46.63, latitude: -23.55), // São Paulo
CityMarker(longitude: 151.21, latitude: -33.87), // Sydney
];
Chart.CoreChart?.Update();
}
// GeoVisualElement re-projects the (Longitude, Latitude) of the visual
// on every measure, so the markers follow pan / zoom / rotation.
private static GeoVisualElement CityMarker(double longitude, double latitude) =>
new(new CityMarkerVisual()) { Longitude = longitude, Latitude = latitude };
}
using LiveChartsCore;
using LiveChartsCore.Drawing;
using LiveChartsCore.SkiaSharpView.Drawing.Geometries;
using LiveChartsCore.SkiaSharpView.Painting;
using LiveChartsCore.VisualElements;
using SkiaSharp;
namespace ViewModelsSamples.Maps.MarkersOnMap;
public class CityMarkerVisual : Visual
{
private const float Size = 14f;
// GeoVisualElement writes the projected pixel onto this geometry, so do not set X or Y
// in Measure below or the marker would ignore the coordinate it is anchored to.
//
// The translate centers the circle on the projected point; without it the geometry's
// top-left corner would sit on the coordinate.
//
// Declared as IDrawnElement rather than CircleGeometry: net462 does not support covariant
// returns, and Measure has no need for the derived type here.
protected override IDrawnElement DrawnElement { get; } = new CircleGeometry
{
Width = Size,
Height = Size,
Fill = new SolidColorPaint(new SKColor(255, 87, 51)), // OrangeRed
Stroke = new SolidColorPaint(SKColors.White),
// A geometry that carries its own paints is drawn with the thickness set here, the one on
// the paint is ignored, so setting it there would silently draw a 1px hairline instead.
StrokeThickness = 2,
TranslateTransform = new(-Size / 2f, -Size / 2f),
};
protected override void Measure(Chart chart)
{ }
}
To place or hit-test something yourself, geoMap.CoreChart.Project(longitude, latitude) returns the pixel of a
coordinate, or null when the coordinate is on the hidden side of the globe. geoMap.CoreChart.Unproject(point)
returns the coordinate of a pixel, or null when the pixel is outside the disc of the globe.
var coordinate = geoMap.CoreChart.Unproject(new LvcPoint(x, y));
if (coordinate is null) return; // the pixel is outside the globe
var (longitude, latitude) = coordinate.Value;
Zooming and panning
InteractionMode enables the zoom and the pan, it is None by default. It is a flag enum:
| Value | Wheel zoom | Drag to pan |
|---|---|---|
None |
no | no |
Pan |
no | yes |
Zoom |
yes | no |
Both |
yes | yes |
<GeoMap
Series="series"
InteractionMode="LiveChartsCore.Geo.MapInteractionMode.Both"> <!-- mark -->
</GeoMap>
The wheel zooms around the pointer. ZoomingSpeed sets how much each step of the wheel zooms, from 0.1 to 0.95,
0.2 by default. The zoom level goes from MinZoomLevel (1 by default) to MaxZoomLevel (100). When the user
releases the pointer, the map springs back to cover the control: it undoes a zoom below MinZoomLevel and a pan that
leaves an empty band at an edge. Dragging an orthographic map moves the globe, it does not rotate it.
From code, the CoreChart of the map has ZoomLevel to read or set the zoom, Zoom(pivot, direction) to zoom around
a pixel, Pan(delta) to move the map by a number of pixels, and ResetViewport() to go back to zoom 1 with no pan.
They work whatever the InteractionMode.
Title and legend
Title draws a visual above the map, and the map leaves room for it. A DrawnLabelVisual draws a text; when its paint
is not set, the theme picks it. For a heat map, set Legend to an SKHeatLegend and LegendPosition to a side,
LegendPosition is Hidden by default. The legend draws the HeatMap of the first series as a gradient, with the
lowest and highest values at its ends; set IsVisibleAtLegend to false on a series to skip it.
geoMap.Title = new DrawnLabelVisual(
new LabelGeometry
{
Text = "World population by country",
TextSize = 20,
Padding = new LiveChartsCore.Drawing.Padding(12)
});
geoMap.LegendPosition = LiveChartsCore.Measure.LegendPosition.Right;
geoMap.Legend = new SKHeatLegend();

These are plain properties of the map, not component parameters: set them through a reference to the control
(@ref).
The map does not redraw when Title, Legend or LegendPosition change; set them before the map is shown, or call
geoMap.CoreChart.Update() after changing them. LegendTextSize and LegendBackgroundPaint style the legend, see
the legends article.
Tooltips
The tooltip opens when the pointer is over a land. It shows the name of the land and one line per series that has a
value for it, in the order of the Series collection; each line is Name: Value with two decimals, or only the
value when the series has no Name.
TooltipPosition places it relative to the center of the land:
| Value | Placement |
|---|---|
Auto |
The default. Above the land, or below it when there is no room above. |
Top |
Always above the land. |
Bottom |
Always below the land. |
Hidden |
No tooltip. |
TooltipTextSize (14 by default), TooltipTextPaint and TooltipBackgroundPaint style the default tooltip, as in
the tooltips article.
TooltipFormatter replaces the text of each value line; it takes a GeoTooltipValue, with the Series and the
Value. Like the title, it is a plain property of the map, set it from code:
geoMap.TooltipFormatter = v => $"{v.Series.Name}: {v.Value:C0}"; // mark
For a different layout, inherit from SKDefaultGeoTooltip and override GetLayout(), or implement IGeoMapTooltip
(its Show() and Hide() methods) from scratch, and assign it to the Tooltip property of the map.
public class MyTooltip : SKDefaultGeoTooltip
{
protected override Layout<SkiaSharpDrawingContext> GetLayout(
GeoTooltipPoint point, GeoMapChart chart, Theme theme, PopUpPlacement placement)
{
// build your own layout here
return base.GetLayout(point, chart, theme, placement);
}
}
geoMap.Tooltip = new MyTooltip();
Pointer events
DataPointerDown fires when the user clicks a land (a press and release that moves the pointer less than 5 pixels),
and HoveredPointsChanged fires when the pointer enters a land, moves to another one or leaves it. Each ChartPoint
in these events has the land as its Context.DataSource, a
LandDefinition with the Name and ShortName
of the land, and TryGetValue on a series returns its value for that land:
using System.Linq;
using LiveChartsCore.Geo;
geoMap.DataPointerDown += (sender, points) =>
{
if (points.FirstOrDefault()?.Context.DataSource is not LandDefinition land) return;
foreach (var series in geoMap.Series ?? [])
if (series.TryGetValue(land.ShortName, out var value))
Console.WriteLine($"{land.Name}, {series.Name}: {value}");
};
geoMap.GetPointsAt(new LvcPointD(x, y)) returns the land at a pixel in the same form, without an event.
Series, names and updates
Landstakes anyICollection<HeatLand>.HeatLandnotifies when itsValuechanges and the map is updated; replacingLands, or adding and removing items of anObservableCollection, updates it too, see automatic updates.- To use your own type instead of
HeatLand, implementIWeigthedMapLandand useHeatLandSeries<TModel>. Nameis shown in the tooltip.- A map can have several series. When two series give a value to the same land, the land takes the color of the last one, and the tooltip shows both values.